<%@page import="com.mongodb.DBObject"%>
<%@page import="com.mongodb.DBCursor"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ page import="com.jiangjun.fetch.mongo.MongoDBSupport"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>抓取源管理</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script>
	function remove(id) {
		alert(id);
		window.location.href = "removeRssAction?id=" + id;
	}
</script>

<style>
body {
	font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica,
		sans-serif;
	color: #4f6b72;
	background: #E6EAE9;
}

a {
	color: #c75f3e;
}

caption {
	padding: 0 0 5px 0;
	width: 700px;
	font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	text-align: right;
}

#mytable {
	width: 1200px;
	padding: 0;
	margin: 0;
}

th {
	font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	color: #4f6b72;
	border-right: 1px solid #C1DAD7;
	border-bottom: 1px solid #C1DAD7;
	border-top: 1px solid #C1DAD7;
	letter-spacing: 2px;
	text-transform: uppercase;
	text-align: left;
	padding: 6px 6px 6px 12px;
	background: #CAE8EA no-repeat;
}

th.nobg {
	border-top: 0;
	border-left: 0;
	border-right: 1px solid #C1DAD7;
	background: none;
}

td {
	border-right: 1px solid #C1DAD7;
	border-bottom: 1px solid #C1DAD7;
	background: #fff;
	font-size: 11px;
	padding: 6px 6px 6px 12px;
	color: #4f6b72;
}

td.alt {
	background: #F5FAFA;
	color: #797268;
}

th.spec {
	border-left: 1px solid #C1DAD7;
	border-top: 0;
	background: #fff no-repeat;
	font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}

th.specalt {
	border-left: 1px solid #C1DAD7;
	border-top: 0;
	background: #f5fafa no-repeat;
	font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	color: #797268;
}
</style>
</head>
<body>
	<div>
		<form action="addRssAction.do" method="post">
			<div>
				<span>源地址：</span> <input type="text" id="url" name="url" /> <br />
				<span>xpath：</span> <input type="text" id="xpath" name="xpath" /> <br />
				<span>描述：</span> <input type="text" id="des" name="des" /> <br />
				<span>类型：</span> <select id="type" name="type">
					<option value="1">图片源</option>
					<option value="2">文字源</option>
					<option value="3">美图集</option>
				</select> <br /> <span>是否为XML：</span> <select id="isRssXml" name="isRssXml">
					<option value="1">是</option>
					<option value="0">否</option>
				</select> <br /> <input type="submit" id="tijiao" name="tijiao" value="添加源" />
			</div>
		</form>
	</div>
	<div>
		<table id="mytable">
			<tr>
				<th>序列号</th>
				<th>ID</th>
				<th>源地址</th>
				<th>XPATH</th>
				<th>描述</th>
				<th>类型</th>
				<th>是否为XML</th>
				<th>是否删除</th>
				<th>操作</th>
			</tr>
			<%
				MongoDBSupport mongoDBSupport = MongoDBSupport.getInstance();
				DBCursor cursor = mongoDBSupport
						.queryCollection(MongoDBSupport._FETCHRSS);
				int count = 1;
				while (cursor.hasNext()) {
					DBObject obj = cursor.next();
			%>
			<tr>
				<td><%=count%></td>
				<td><%=obj.get("id").toString()%></td>
				<td><%=obj.get("url").toString()%></td>
				<td><%=obj.get("xpath").toString()%></td>
				<td><%=obj.get("des").toString()%></td>
				<%
					if ((obj.get("type").toString()).equals("1")) {
				%>
				<td>图片源</td>
				<%
					} else if ((obj.get("type").toString()).equals("2")) {
				%>
				<td>文字源</td>
				<%
					} else if ((obj.get("type").toString()).equals("3")) {
				%>
				<td>美图集</td>
				<%
					}
				%>
				<%
					if (obj.get("isRssXml").toString().equals("1")) {
				%>
				<td>是</td>
				<%
					} else {
				%>
				<td>否</td>
				<%
					}
					if (obj.get("isDelete") != null && obj.get("isDelete").toString().equals("0")) {
				%>
				<td>是</td>
				<%
					} else {
				%>
				<td>否</td>
				<%
					}
				%>
				<td><a
					href="removeRssAction.do?id=<%=obj.get("id").toString()%>">【删除】</a>
					<a href="backRssAction.do?id=<%=obj.get("id").toString()%>">【恢复】</a></td>
			</tr>
			<%
				count++;
				}
			%>
		</table>
	</div>
</body>
</html>
